<template>
	<view class="goodWrapper">
		<view class="status_bar">
			<!-- 这里是状态栏 -->
		</view>
		<view class="goodHeader">
			<view class="goodHeaderContaint">
				<text class="pd" @tap="back()"></text>
				<text class="title">采购订单</text>
				<view class="options">
					<button class="setting"></button>
					<button class="addGoods" style="display: none;"></button>
				</view>
			</view>
		</view>
		<view class="goodContainer">
			<view class="searchInput">
				<view class="goodType">
					<text @tap="showType()">{{typeName}}&nbsp;></text>
					<view class="allGoodsType" v-if="isShowGoodsType!=0">
						<view class="typeTitle" @tap="setTypeName('全部')">全部<text class="pulljt">></text></view>
						<text class="typeItem" @tap="setTypeName('平板电脑')">平板电脑</text>
					</view>
				</view>
				<view class="goodFilter">
					<uniIcon type="search" size="14" style="line-height: 28px;margin-left: 5px;margin-right: 5px;color: #a7aab3;" /><input
					 placeholder="单号/供应商名称" class="searchOption"></input>
				</view>
				<view class="searchOptions">
					<button class="giveSong"></button>
					<button class="getPicture" @tap="getSm()"></button>
				</view>
			</view>
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper" @scrolltolower="lower"
			 @scroll="scroll">
				<view class="goodsItem" v-for="(item,index) in orderList" :key="index" @tap="navigatorTo()">

					<view class="goodInfo">
						<text class="goodName">{{item.title}}</text>
						<view class="priceWrap">
							<view class="price">
								<text>批发:{{item.price}}</text>
								<text>日期:{{item.date}}</text>
							</view>
							<view class="price" >
								<image src="" mode="" class="addGood"></image>
							</view>
							<!-- <view class="addGood" v-if="type!=0">
								<button></button>
							</view> -->
						</view>
					</view>
				</view>

			</scroll-view>
		</view>
		<view class="goodsCount">
			订单数量：{{orderList.length}}
		</view>

	</view>
</template>
<script>
	// import allConst from "../../Json.js"
	import uniIcon from '@/components/uni-icon/uni-icon.vue';
	export default {
		data() {
			return {
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				orderList: [
					{
						title: "供应商",
						price: "DH-123245345345234",
						sales: 61,
						date:"2019-1-10"
					},
					{
						title: "供应商02",
						price: "DH-123245345345234",
						sales: 61,
						date:"2019-1-10"
					},
					{
						title: "供应商03",
						price: "DH-123245345345234",
						sales: 61,
						date:"2019-1-10"
					},
					{
						title: "供应商04",
						price: "DH-123245345345234",
						sales: 61,
						date:"2019-1-10"
					}
				],
				isShowGoodsType: 0,
				typeName: "全部",
				type: 0,
				isShowCar: false
			}
		},
		created() {

		},
		onLoad(options) {
			this.type = options.type;
		},
		components: {
			uniIcon
		},
		methods: {
			back: function() {
				uni.navigateBack({
					delta: 1
				})
			},
			//关闭购物车
			cancelCar: function() {
				this.isShowCar = false
			},
			//开启购物车
			openCar: function() {
				this.isShowCar = !this.isShowCar
			},
			getSm: function() {
				uni.scanCode({
					success: function(res) {
						alert(res.result);
					}
				});
			},
			navigatorTo() {
			
					uni.navigateTo({
						url: './detail/detail',
					});
		

			},
			setTypeName: function(msg) {
				//获取点击对象      
				this.typeName = msg;
				this.isShowGoodsType = 0;
			},

			//显示全部分类
			showType: function() {
				if (this.isShowGoodsType == 0) {
					this.isShowGoodsType = 1;
				} else {
					this.isShowGoodsType = 0;
				}

			},
			upper: function(e) {
				console.log(e)
			},
			lower: function(e) {
				console.log(e)
			},
			scroll: function(e) {
				console.log(e)
				this.old.scrollTop = e.detail.scrollTop
			},
			goTop: function(e) {
				this.scrollTop = this.old.scrollTop
				this.$nextTick(function() {
					this.scrollTop = 0
				});
				uni.showToast({
					icon: "none",
					title: "纵向滚动 scrollTop 值已被修改为 0"
				})
			}
		}
	}
</script>
<style>
	@import url("./add-order.css");
</style>
